    // 二叉树的最近公共祖先
    let root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1
    let parent, visited
    var lowestCommonAncestor = function(root, p, q) {
         parent = new Map()
         visited = new Set()
         dfs(root)

         while(p != null) {
             visited.add(p.val)
             p = parent.get(p.val)
         }

         while(q != null) {
             if (visited.has(q.val)) {
                 return q
             }
             else q = parent.get(q.val)
         }
    };

    function dfs(root) {  // 把二叉树的结构整理成对象
        if(root.left != null) {
            parent.set(root.left.val, root)
            dfs(root.left)
        }
        if (root.right != null) {
            parent.set(root.right.val, root) 
            dfs(root.right)
        }
    }

    let tree = {
        val: 3,
        left: {
            val: 5,
            left: {
                val: 6
            }
        },
        right: {
            val: 1,
            left: {

            }
        }
    }